import { get, post, put } from '../../utils/request';

interface Rresponse {
  code: number;
  msg: string;
  status: boolean;
  data: any;
  fail: boolean;
}

interface DocumentInfo {
  id: string;
  title: string;
  content: string;
  type: string;
  keywords: string;
  remark: string;
  sessionId: string;
  chatSessionId: number;
}

/**
 * 新增写作记录
 * @param data DocumentInfo
 */
export const addDocument = (data: DocumentInfo): Promise<Rresponse> => {
  return post('/api/starhub/writing', data);
};

/**
 * 编辑写作记录
 * @param data DocumentInfo
 */
export const updateDocument = (data: DocumentInfo): Promise<Rresponse> => {
  return put('/api/starhub/writing', data);
};


/**
 * 获取写作历史
 * @param pageNum 页码
 * @param pageSize 每页数量
 */
export const page = (pageNum = 1, pageSize = 10) => {
  return get('/api/starhub/writing/list', { pageNum, pageSize });
};

/**
 * 添加到知识库
 * @param id recordId
 */
export const addToArchive = (id: string): Promise<Rresponse> => {
  return post('/api/starhub/writing/addToArchive/' + id);
};


/**
 * 获取用户列表
 */
export const getUserList = async (): Promise<Rresponse> => {
  return get('/api/starhub/user/getList');
};
